<?php

use Phinx\Migration\AbstractMigration;

class CreateReviewRequestNode extends AbstractMigration
{
    /**
     * Change Method.
     *
     * Write your reversible migrations using this method.
     *
     * More information on writing migrations is available here:
     * http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
     *
     * The following commands can be used in this method and Phinx will
     * automatically reverse them when rolling back:
     *
     *    createTable
     *    renameTable
     *    addColumn
     *    addCustomColumn
     *    renameColumn
     *    addIndex
     *    addForeignKey
     *
     * Any other destructive changes will result in an error when trying to
     * rollback the migration.
     *
     * Remember to call "create()" or "update()" and NOT "save()" when working
     * with the Table class.
     */
    public function change()
    {
        $table = $this->table('review_request_node', ['id' => false, 'primary_key' => ['id'], 'engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', "comment" => "审核申请审批节点表"]);

        //添加数据字段
        $table->addColumn('id', 'integer', ['identity' => true, 'signed' => false, 'limit' => 11, 'comment' => '节点ID'])
            ->addColumn('review_request_id', 'integer', ['signed' => false, 'default' => 0, 'limit' => 11, 'comment' => '审批申请ID'])
            ->addColumn('role_code', 'string', ['null' => false, 'limit' => 255, 'default' => '', 'comment' => '角色CODE'])
            ->addColumn('parent_id', 'integer', ['signed' => false, 'limit' => 11, 'default' => 0, 'comment' => '父级节点id'])
            ->addColumn('plan_reviewer', 'integer', ['signed' => false, 'limit' => 11, 'default' => 0, 'comment' => '计划审核人ID'])
            ->addColumn('real_reviewer', 'integer', ['signed' => false, 'limit' => 11, 'default' => 0, 'comment' => '审核人ID'])
            ->addColumn('is_pass', 'enum', ['values' => 'yes,no', 'default' => 'no', 'comment' => '是否通过'])
            ->addColumn('is_reviewed', 'enum', ['values' => 'yes,no', 'default' => 'no', 'comment' => '是否审核'])
            ->addColumn('is_active', 'enum', ['values' => 'yes,no', 'default' => 'no', 'comment' => '是否激活'])
            ->addColumn('created', 'integer', ['signed' => false, 'default' => 0, 'limit' => 11, 'comment' => '创建时间'])
            ->addColumn('uuid', 'char', ['default' => '', 'limit' => 36, 'comment' => '全局唯一标识符'])
            ->addColumn('reviewed', 'integer', ['signed' => false, 'default' => 0, 'limit' => 11, 'comment' => '审核时间']);

        //执行创建
        $table->create();
    }
}
